package kr.hkit.coffeemgn.DTO;

import kr.hkit.framework.util.MathUtil;


public class CoffeeDTO implements Comparable<CoffeeDTO> {
	private int rank;
	private String pCode;
	private String pName;
	private int pCost;
	private int pCnt;
	private int pRate;
	
	private int totalSale;
	private int totalTax;
	private int totalPush;
	private int totalRate;
	
	public CoffeeDTO() {}

	public CoffeeDTO(String pCode, String pName, int pCost, int pCnt, int pRate) {
		this.pCode = pCode;
		this.pName = pName;
		this.pCost = pCost;
		this.pCnt = pCnt;
		this.pRate = pRate;
	}

	public int getTotalSale() {
		return totalSale;
	}

	public void setTotalSale(int totalSale) {
		this.totalSale = totalSale;
	}

	public int getTotalTax() {
		return totalTax;
	}

	public void setTotalTax(int totalTax) {
		this.totalTax = totalTax;
	}

	public int getTotalPush() {
		return totalPush;
	}

	public void setTotalPush(int totalPush) {
		this.totalPush = totalPush;
	}

	public int getTotalRate() {
		return totalRate;
	}

	public void setTotalRate(int totalRate) {
		this.totalRate = totalRate;
	}

	public int getRank() {
		return rank;
	}

	public void setRank(int rank) {
		this.rank = rank;
	}

	/**
	 * 판매금액
	 * @return
	 */
	public int calSaleCost(){
		return pCost * pCnt;
	}
	
	public int calAddTax(){
		double tax = calSaleCost() / 11.0;
		return (int) Math.ceil(MathUtil.getDecimalPosition(tax, 1));
	}
	
	public int calPushCost(){
		return calSaleCost()-calAddTax();
	}
	
	public int calRateCost(){
		return (int) Math.round(MathUtil.getDecimalPosition(calPushCost() * (pRate/100.0), 1));
	}
	
	public String getpCode() {
		return pCode;
	}

	public void setpCode(String pCode) {
		this.pCode = pCode;
	}

	public String getpName() {
		return pName;
	}

	public void setpName(String pName) {
		this.pName = pName;
	}

	public int getpCost() {
		return pCost;
	}

	public void setpCost(int pCost) {
		this.pCost = pCost;
	}

	public int getpCnt() {
		return pCnt;
	}

	public void setpCnt(int pCnt) {
		this.pCnt = pCnt;
	}

	public int getpRate() {
		return pRate;
	}

	public void setpRate(int pRate) {
		this.pRate = pRate;
	}

	@Override
	public String toString() {
		return String
				.format("CoffeeDTO [pCode=%s, pName=%s, pCost=%s, pCnt=%s, pRate=%s, calSaleCost()=%s, calAddTax()=%s, calPushCost()=%s, calRateCost()=%s]",
						pCode, pName, pCost, pCnt, pRate, calSaleCost(),
						calAddTax(), calPushCost(), calRateCost());
	}

	@Override
	public int compareTo(CoffeeDTO o) {
		return o.calSaleCost()-this.calSaleCost();
	}
	
	
}
